In encoding of a video signal, it is necessary to perform the encoding in such a manner that a decoder does not collapse. In an H.264 encoding scheme, a hypothetical decoder, HRD (Hypothetical Reference Decoder), obtained by modeling a decoder is defined. An H.264 encoder should perform encoding in such a manner that the hypothetical decoder does not collapse. The present invention is technology for suppressing collapse of a CPB of a hypothetical decoder, specifically, underflow of the CPB.
In FIG. 1, a conceptual diagram of the CPB underflow is illustrated. In the case of a constant bit rate, an encoded stream is input to the CPB at the bit rate, as indicated by an arrow A1. A data amount of the encoded stream in the CPB each time is referred to as a “residual bit rate.” The hypothetical decoder pulls out the encoded stream corresponding to each picture from the CPB. In this case, the CPB residual bit rate is instantly reduced by a bit rate corresponding to the picture. An illustrative case of the constant bit rate is illustrated, but the same applies to a case of a variable bit rate.
The CPB underflow refers to a situation in which the encoded streams of the pictures are insufficient in the CPB when the hypothetical decoder attempts to pull out the encoded streams of the pictures in each time indicated by an arrow A2, as illustrated in FIG. 1. In H.264-based encoding, a state of the CPB should be verified while encoding is being performed to produce a stream not causing the CPB underflow. As described above, the CPB of the hypothetical decoder is standardized in H.264 and further details are described, for example, in the following Non-Patent Document 1.
Further, the same concept as the CPB is also defined in other encoding standards. For example, in MPEG-2, there is a VBV (video buffering verifier), and a buffer model of such a decoder is herein referred to as “a hypothetical buffer.” In the following description, a “CPB” may be substituted with the term “hypothetical buffer” for interpretation in a broader sense.
Methods of encoding of a video signal include 1-pass encoding technology and multi-pass encoding technology. In the 1-pass encoding, generally, pictures of an input video are sequentially encoded. On the other hand, in the multi-pass encoding, an input video is encoded multiple times. In 2-pass encoding, second encoding is performed using a result of first encoding. Hereinafter, related art of the 1-pass encoding is referred to as “related art a” and related art of 2-pass encoding is referred to as “related art b.”
<Related Art a>
In 1-pass encoding, since input pictures are sequentially encoded, the nature of a future picture after an encoding target picture is unknown. Accordingly, while there is an attempt to suppress the CPB underflow using 1-pass encoding, a generated bit rate is suppressed more than necessary and video quality is greatly degraded more than necessary. For example, in the technology of Patent Document 1, degree of complexity of a video obtained from a result of encoding in the past is used as an estimate of degree of complexity of other videos of a GOP before each picture is encoded. Under the premise of the estimate of the degree of complexity, a quantization parameter causing a maximum bit rate that can be used to encode the other videos of the GOP is estimated and used as a lower limit value of a quantization parameter during encoding of the encoding target picture. There is a problem in that the bit rate is suppressed more than necessary, causing degradation of video quality, when the other videos of the GOP are not complex in comparison with the estimated degree of complexity.
<Related Art b>
In 2-pass encoding, all pictures of an input video are encoded, and a bit rate of each picture generated at this time is used for second encoding. In this method, degree of complexity of each portion of the video can be recognized at the time of second encoding, unlike the case of the 1-pass encoding. Accordingly, the CPB underflow can be expected to be suppressed with degradation of video quality being suppressed. For example, in the technology of Patent Document 2, in first encoding, degree of complexity of each frame is obtained and an allocated bit rate of each frame is obtained. Also, it is verified if the CPB underflow occurs with the allocated bit rate. When the CPB underflow occurs, the allocated bit rate is modified. In other words, since the degree of complexity of each frame is recognized, the allocated bit rate can be modified only when the CPB underflow occurs. As a result, the CPB underflow can be suppressed while keeping video quality degradation smaller, as compared to related art a. However, in this method, there is a problem in that a calculation amount increases since all frames of an input video need be encoded twice.